<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/semantic/semantic.min.css}"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css">
</head>
<div style="margin:50px 50px 50px 50px">
    <form class="layui-form layui-form-pane" lay-filter="staffInfo">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><i class="ui blue book icon"></i>员工编号</label>
                <div class="layui-input-block">
                    <input type="text" disabled name="staffId" required lay-verify="required" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><i class="ui blue book icon"></i>员工姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="staffName" required lay-verify="required" autocomplete="off"
                           placeholder="请输入员工名" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><i class="ui blue user outline icon"></i>员工类型</label>
                <div class="layui-input-inline">
                    <select name="staffType" lay-verify="required">
                        <option value="">请选择类型</option>
                        <option value="0">普通员工(学徒)</option>
                        <option value="1">普通员工(熟手)</option>
                        <option value="2">前台</option>
                        <option value="3">主管</option>
                        <option value="4">管理员(老板)</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><i class="ui violet user outline icon"></i>密码</label>
                <div class="layui-input-block">
                    <input type="text" name="staffPassword" required lay-verify="required" autocomplete="off"
                           placeholder="请输入密码" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><i class="ui blue font icon"></i>选择团队</label>
                <div class="layui-input-inline">
                    <select name="staffTeam" lay-verify="required">
                        <option value="">请选择团队</option>
                        <option value="1">建模</option>
                        <option value="2">渲染</option>
                        <option value="3">后期</option>
                        <option value="4">管理</option>
                        <option value="5">其他</option>
                    </select>
                </div>
            </div>
        </div>


        <div class="layui-form-item">

            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-danger">重置</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" th:src="@{/js/jquery-3.4.1.min.js}"></script>
<script type="text/javascript" th:src="@{/semantic/semantic.min.js}"></script>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/upload.js}"></script>
<script th:inline="javascript">
    layui.use(['form', 'layedit', 'laydate'], function () {
        const form = layui.form
            , layer = layui.layer;
        form.render('select');
        //监听提交
        const staff = [[${staff}]];//得到model中的client
        form.val('staffInfo', {
            "staffId": staff.staffId
            , "staffName": staff.staffName // "name": "value"
            , "staffPassword": staff.staffPassword
            , "staffType": staff.staffType
            ,"staffTeam":staff.staffTeam
        });
        form.on('submit(demo1)', function (data) {
            $.ajax({
                url: "/staff/update",
                method: "post",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(data.field),
                dataType: "json",
                success: function () {
                    layer.alert('修改成功', {
                        icon: 1,
                        skin: 'layer-ext-moon'
                    })
                }
            })
            return false;
        });
    });
</script>